class ApplicationController < ActionController::Base

  protect_from_forgery

  before_filter :authorize, :except => :login
  helper :all




  protected
  def current_user
      current_user = User.find_by_id(session[:user_id])
  end

  def authorize
    unless User.find_by_id(session[:user_id])
      #session[:original_uri] = request.request_uri
      flash[:notice] = "Please log in"
      redirect_to(:controller => "dashboard", :action => "login")
    end
  end

  rescue_from CanCan::AccessDenied do |exception|
  flash[:error] = "Access denied."
    redirect_to dashboard_index_path
  end

end
